<template>
  <div id="app">
    <h1>MockJs</h1>
    <hr />
    <button @click="getGoodsList">获取商品列表</button>
    <button @click="addGoods">添加商品</button>
    <button @click="addGoodsDetail(2)">商品详情</button>

  </div>
</template>

<script>

export default {
  name: 'App',
  methods: {
    async getGoodsList () {
      const { data: res } = await this.$http.get('/api/goodslist')
      console.log(res)
    },
    async addGoods () {
      const { data: res } = await this.$http.post('/api/addgoods', {
        name: '小米手机',
        price: 1999
      })
      console.log(res)
    },
    async addGoodsDetail (id) {
      const { data: res } = await this.$http.get(`/api/goodsdetail/${id}`)
      console.log(res)
    }

  }
}
</script>
<style></style>
